minor pep8 and fix depricated key checks

- Minor code reformatting based on PEP8
- Switched to 'in' from depricated has_key
- Define IOError instead of broad except