Ported base64 conversion functions

Gracefully borrowed from the luausers wiki. Allows use of custom
alphabet!