freq.py: fix problem where encoding=None if redirecting stdout to a file