Fix rescaling bug
This addresses issue #57 that was caused by average images calculated
for pixel classification potentially being outside of the allowed range.
Now all images are rescaled to the allowed value range.
The implementation was done such that backwards compatibility is preserved.