fix bug 1037537 - encode utf-8 properly, and remove NULL characters whic...

...h postgres will not allow to be imported into TEXT NOT NULL columns