Hopefully fixed the frame-rate control code.

Now when it measures the elapsed time (to decide how long to wait for each loop), the measurement includes the time spent retrieving an image from the camera, which is the slowest part so far.
Also, video saving should take frame-rate into account correctly now.