Test for the bug with TypeError while saving BytesIO object.