Reordered IPython imports to avoid deprecation warning

The frontend package is now deprecated (since IPython 1.0). The
corresponding deprecation warning has been avoided by reordering the
necessary imports.