Support environments without a home dir or writable file system

This patch makes it possible to import and use matplotlib on a system where the user has no $HOME directory, and furthermore, on which there is no writable file system. It does this by:
* Falling back to creating a temporary config directory instead of raising `RuntimeError` if the user has no $HOME directory.
* Falling back to not writing to the config dir if it is not possible to create a temporary directory. (In this case, all caching mechanisms, including texmanager, font_manager and finance, are disabled.)

Partial fix for Issue #1823.