Please note that the parameter named base64 for resource_pb2.Image doesn't take base64-encoded bytes, but simply a bytes object. Our library automatically converts the file bytes to base64.
You are able to retrieve the value from the BytesIO object directly (bytesIOImage.getvalue()) instead of converting it to base64.