Tweak the Cut
Even on perfectly square corners, 45-degree angles won't always yield perfect miters. Wall corners can be built up with corner bead and compound, and window and door frames can slightly protrude or be recessed behind surrounding drywall. That's when you have to start fiddling with the angles to get a tight fit. In most cases, you'll be making adjustments as small as a quarter of a degree. If the gap is small (about 1/16 in.), recut one side of the miter. If the gap is larger, you'll have to recut both boards or the trim profiles wont line up.
Glue and Sand for a Seamless Fit
Here's a trick to make miters look great, but it only works if you're installing raw trim that will get finished after installation. Apply a thin layer of wood glue to the end grain of each piece before you assemble them. Use a damp (not wet) cloth to remove excess glue from the joint. Sand over the miter with a small piece of 120-grit sandpaper. Sand across the joint and finish up by carefully sanding out any cross-grain sanding marks by moving the paper with the grain from both directions.The sawdust from sanding will mix with the glue to fill any small gaps. Sanding the miter will also even out any slight level differences and make the job look more professional.
Burnish the Corner
If your baseboard or crown molding has a slight gap in the outside corner miter, you can hide it by rubbing the tip of the miter with the shank of a screwdriver or nail set. The bent fibers will disguise the gap, and the slightly rounded corner will be less likely to get chipped or damaged. The best way to prevent this problem is to cut your outside corner miters about 1 degree sharper than the actual angle so the tips of the miters touch. This will leave a tiny gap at the back of the miter where it's barely noticeable.