Fix gen_rst.py to use the correct encoding even on Python 2.
Merge pull request #1897 from mdboom/doc/encoding_gen_rst

Fix documentation build failure (unicode error in generate_example_rst)