Writing 8- and 16-bit numbers to memory