Write Encoded function and Constant

Function to write out a file encoded to a specific encoding. Seems to
work well. This works on a basic install of wordpress pretty well.

It seems to explode horribly when I apply it to any website with
GroupBuyingSite code though. I get a validation error, so the JSON seems
to be wrong somehow.