Browser-safe base64 implementation