Python 3.x compatibility

Some mechanical translation to improve compatibility
with Python 3.x

Change-Id: I47b930be9f5d76f99001c2a202c689c0c1f91e65