fix a bug while reading and writing gists containing CJK characters under Python2

Gists containing CJK characters will raise `'ascii' codec can't encode characters` under Python 2.

The modified code fix this bug and works well under both Python 2 and Python 3.