Measure the width of the top of the doorway from the inside of each upper corner. Transfer this measurement to a piece of door trim, with two marks on the bottom edge and the measured span between them.
Lay the trim on a miter saw, facing up, so the bottom edge is along the back rail of the saw. Swivel the blade to point 45 degrees outward, toward the closest end of the trim. Make the cut.
Slide the trim so the other mark is positioned under the blade. Swivel the blade to 45 degrees in the opposite direction from where it was before, again pointing toward the end. Make the cut.
Hold the trim along the top of the doorway so the measured bottom edge is lined up with the edge of the casing and the two angled cuts rise out and up past the upper corners. Set the piece in place with a finish nailer, shooting the nails every 10 to 12 inches along the upper and lower edges of the piece.
Measure for the first vertical side piece. Cut the upward-facing end with a 45-degree miter as before. Cut the downward-facing end at 90 degrees --- straight across --- so it can sit flat on the floor. Nail in the piece with the mitered end butting to the mitered end of the top piece, thus forming the corner.
Repeat for the other vertical span of the doorway.
Use a caulking gun to caulk around the edges of the trim where it meets the wall. Smooth down the caulk with a moistened fingertip.