Fix I/O of hexadecimal numbers, calculate block_mask