trying to work around tempfile write issue on python3