Fix warnings under Python 3.
Use new importlib.machinery module if available.