Use python's base64 library.