byte is a signed type in java, so we need to mask it with &0xFF, see http://stackoverflow.com/questions/11380062/what-does-value-0xff-do-in-java