Measure the width and height of the opening, from inside the tracks where the sashes are trapped. Measure from several different points along the height and width, looking for variations caused by the movement of the house over time. Order the new window unit using the smallest measurements you come up with.
Measure the new window unit when it arrives, to ensure it's correct. Take out the existing window by prying off the trim around the interior edge with a hammer and flatbar. Keep the trim intact as you remove it, as you will have to re-use it later.
Put the new window unit in the opening, bottom first, and then push the top until it butts to the trim around the exterior.
Put a level alongside the window unit and slide shims in around the edges.
Drive long screws through the holes in the sides of the window unit, outward into the surrounding frame.
Use spray foam insulation to fill the spaces around the edges of the window unit.
Set the trim back in around the window unit, covering the spaces, with finishing nails, driving them with your hammer. Caulk the perimeter of the trim.