how to write a python file onto memory