Protect exposure.histogram from integer overflow

Fixes #1228 .

I also removed a min() calculation and prevented an image copy when
offset is 0, which is most of the time.
Merge pull request #1232 from jni/negative-histogram

Protect exposure.histogram from integer overflow