Serialize/Deserialize use a different header that includes the length of each
length. This ensures the first byte of the message is never \x00, which caused
a problem when converted to an int.

Updated key_encode and key_decode to use the new serialize/deserialize functions.