I am by no means an expert but from my reading on the subject, if your knees are hurting, you might be riding too high a gear. Need to shift to a lower, i.e. easier, gear and spin faster. Here is some information I have found useful:
Bicycling and Pain
Good luck!