Check the window jamb to ensure it is in good working order and that it is nailed tight. Check especially for cracks and rotten wood. If any parts of the jamb need to be replaced, do so.
Locate the studs both above and below the window. They do not have to necessarily line up with each other. In fact, there is no guarantee that you will find a framing member at each end of the window. But still this is a good assumption, so first check to make sure the stud that holds the jamb is continuous in both directions. Do this by banging on the wall with your hammer and then driving a nail part way into the wall when you think that you have located a stud. You will know it when your nail finds a wooden stud.
Cut the top piece of the window trim with a 45-degree cut on each end. For trim material you can use a beveled molding like the clamshell or just use the 1 by 4 wood stock of your choosing.
Attach this piece of trim so the bottom edge of the board is flush with the inside edge of the jamb. (You can leave a 1/4-inch space on the inside surface of the jamb if you like.) Secure the trim to the studs in the wall and the jamb with #8 finish nails.
Cut two vertical pieces so that they are a little bit on the long side. Lay each one in place and mark the angular cuts with a pencil. Do this instead of using a miter box. If there is a sill present, mark the square edge as well as the 45-degree edge. Do the square edge first and set it back in place and then mark the angle. Make sure the trim is flush with the edge of the jamb. If there is no trim, hold the board in place and mark both angled cuts (top and bottom) while the board is in place and then make your cuts. You might need someone to help hold the board for you. Attach the side pieces in the same way as you did the top and bottom.
Set all nails and fill with wood putty once all four pieces are in place and you are happy with the way that they line up. You might have to pull off a board and adjust the cut or round off a corner.