The original windows in the bedrooms in my old house were huge, far too big for the size of the rooms. At some point a previous owner replaced them with much smaller windows, building a frame to hold them in the original opening.

I'm planning to replace those windows with something in between which will mean building a new frame. In at least once case, I would like to use the original framing at the side of the window. However, due to settling and some warping of the original house frame, the openings are not perfectly square. I would like to build the frame in advance so that when the time comes, I can just take out the existing windows, cut out the existing frame, put in the new frame and attach the windows.

Beyond careful measuring twice and cutting once, what do I need to do to ensure that the new frame will fit in the opening and be square so that the window installation will go smoothly?