Handle message encoding properly