Use [...]uint8 instead of [9]uint8 for mask.
Check the error return from nextByte.