PY3: safe open in memory.py
Guard open calls with with statements when possible
Merge pull request #124 from larsmans/with-statements

Some more with statements