Fix relative import for Python 3
Change from except-comma syntax to except-as syntax for Python 3
compatibility
Make code Python 3 compatible