plaintext = input(\"Please enter the text you want to compress\") filename = input(\"Please enter the desired filename\")
You can not serialize a Python 3 'string' to bytes without explict conversion to some encoding.
outfile.write(plaintext.encode('utf-8'))
is possibly what you want. Also this works for both python 2.x and 3.x.