fixed in memory file saving and base64 encoding for python 3