Python3: do not use the 'file' type

It does not exist in Python 3, so we have to use a workaround.

Change-Id: Ib41b5d12102707004b354835265861710aaba568
Closes-Bug: 1287728
Python 3: do not use __builtin__

Use six.moves.builtins instead, this works with both Python 2 and 3.

Change-Id: I17cdf651edbf7907e2b8b3d6aec9ace8a76b0110
Closes-Bug: 1289107
Merge "Python3: do not use the 'file' type"
Merge "Python 3: do not use __builtin__"