fix tests by using a tempfile instead of BytesIO