fix unclosed file ResourceWarning

part of #2830
remove unused import
use importlib.machinery to load modules instead of imp under Python 3.3 and greater

part of #2830
Merged in goodscloud/sqlalchemy (pull request #14)

fixes for #2830
changelog