changed to unsigned char in write()