JPEG decoding broken with 16 bit depth

Turned out to be a silly copy-paste error in the RGB conversion routine. Updated the tests to catch the problem as well.