Speed up pixel access by directly reading from uchar* data.

This makes the code uglier, but faster.  Profiling showed that accessing
the pixels took up 20% of the time.

Also it is important to note that call QImage::bits will copy all of the
image data if the image is not const.