fix base64 encoding bugs