There are different solutions for each of these problems.
Staining caused by rust from old nails should be rubbed down to remove the rust, then prime any exposed metal with a good metal primer before painting.
Resin bleeding from knots in wood should first be removed with turpentine. Then seal the knots with two coats of a suitable knotting solution and repaint.
All solvent-based paints such as gloss will discolour or yellow with age. To treat, wash the surface thoroughly with detergent solution, rinse with clean water and allow to dry before repainting.
If the wood appears to be dirty, particularly around glazing rebates, it may be affected by fungal growth. Clean the surface thoroughly and treat with domestic bleach, or a fungicidal wash, before painting.