[FIX] Support Python 3 uploads

This fixes bugs in uploads with Python 3 (and fixes using MIME mode
with requests).

As Python 3 email does not correctly handle Content-Transfer-Encoding of
'binary', a workaround class CTEBinaryMIMEMultipart is used to strictly
emit the payload unmodified.

It now also closes the file and uses open() as file() has been removed
in Python 3.

Also some Pep257 fixes included.

Change-Id: I9e73d00fc59fd43a5eb6d55efdbf02dd8e605014
Merge "[FIX] Support Python 3 uploads"