py3 compat: Open file as binary when serializing
Merge pull request #249 from uholzer/bug-serialize

Serializing to a file fails in Python 3 --- good catch! Thank you.