Test/fix up file reading and bit masking.

Seems to be working now.
Tested with a few different window masks.