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.