check for stdout.encoding before doing encoding in pytest

This is a fix for a buglet I noticed when doing ``python setup.py test -R >somefile 2>&1``.  Right now when running the tests, our pytest plugin encodes based on `sys.stdout.encoding`.  But apparently that's None if you redirect to a file (at least on a Mac).  So this just adds a check to make sure that encoding is present, and otherwise defaults to ascii (which is what the `plat` string does further up)