Sanitize non utf-8 values when json encoding a record to be written

This resolves issue #25.  It should be backwards compatible and should not cause issues if iconv is not available.