Fix TypeError while saving bytes on python 3