exception handling to Python 3 + PEP 8
inconsistent tabs and spaces fixed to spaces only