generalize base64 methods