Run tests on Travis and fix some compatibility issues

What is "obj" here? Note that we do close the fd later, with os.close.