Fixes for uint32 images

Several semi-related items to fix handling of uint32 images. These don't come up often, though an example would be OpenEXR with uint32 pixels representing object IDs.

The big offenders tended to be places where we used (signed) int values for quantization constants, which just didn't have enough range to properly hold a UINTMAX. Changing a bunch of those places to 'long long' does the trick.