Fix color scaling in tiff loading

Actually the loading wasn't exactly right. The bit expansion should cycle instead of zeroing the extra bits.

Here is a fix. Only the last commit is new.

Most are just coefficients. I have no idea about the speed of expand12to16 - whether it will be inlined etc.