Add ipython 1.x support

Version 0.2.2 does not work with ipython 1.x. This pull requests fixes this bug.

In addition the source code was formatted to satisfy PEP8 guidelines.