Fix CSV method to work with Python 3

Just a couple of compatibility fixes for the CSV output function; in Python 3 there's no need for the encoding-decoding dance, as string objects are already unicode-aware. That fun job can be offloaded to the file stream object.