Supports locale-specified encoding for rcfile.

This commit fixes issue #1317.  The locale for the encoding is obtained from
the Python `locale` module, which can be specified by the `LANG` environment
variable.

This was tested by adding a test rc file encoded in UTF-32-BE, and testing that
it decoded correctly.
I think this will end up changing the rcParams, which may cause subsequent tests to fail if they rely on the rcParams being a certain thing.  We may have to test lower down by calling _open_file_or_url directly.