Backport tokenize.open from Python 3.2

If tokenize.open is not available for opening python files, use the
version of detect_encoding available in lib2to3 and copy the open
wrapper from Python 3.2. Remove the ipython requirement.