encode messages