Use NamedTemporaryFile instead, it is cleaner. Bug #2