Improved loading files
Ported to Python 3