decreased message overhead from 6 bytes to 4 bytes

using a 3-byte integer for message length, and 1-byte for message type

Messages bigger than (2 << 23) - 1 will not be sent, likewise for
messages typed over 255.