Use base64 module to encode as bytes does not have an encode method on python3