Added encoding argument for csv writer.