Completely reimplement base64 encoding/decoding routines