Encode and decode messages so they send properly