Small fixes to support Python 3

Fix a number of small things to support Python 2.6, Python 2.7 as
well as Python 3.3.

Change-Id: I213c847c93cfe3d7f1fd8c8ea4709b7980fd52f9
Merge "Small fixes to support Python 3"