Fixes encoding in >= 1.9.2

Adds encoding magic needed for writer.rb