Fix type checking in loadJpeg

Hi Tim

This pull-request fixes the bug I mentioned a minute ago in the type-checking of the argument in loadJpg. It also adds a totem-based unit test.