Fix bugs in lut reading code

The previous code was incorrectly adapted from IJ1's LutLoader class.
The latest code more closely follows IJ1's logic for reading legacy
luts.