To make this work with all the supported versions, you need to pass `bytes` to `b64encode` function. You also need to make sure that the return value is a string since `b64encode` returns `bytes` by default in Python 3 and above.

You can see how other drivers handle this here - https://github.com/apache/libcloud/blob/trunk/libcloud/compute/drivers/ibm_sce.py#L65