Base64-encode messages and fix ack bug