+1 on the stretching. Warm up by riding gently for a mile or two, then get off and spend 5 minutes stretching.
Also, how's your form? I know my knees will hurt more when I pedal "toes down". When I come around the top of my stroke, I drop my heel just a bit and that always reduces my knee problems.
Lastly, try to keep your knees close to the top tube. If your legs are splayed open when you pedal, this could cause knee trouble as well.