Use BytesIO/StringIO instead of temporary files