base64: Improve error handling