Use os.open to ensure that files for the cache have correct perms

The previous file handling code suffered from a few issues.

1. It would only create the leaf directory if it didn't exist but would error if any parent directories didn't exist. This will use os.makedirs to create anything needed.
2. Directories created by FileCache uses the default umask, instead we'll make this configurable and make it default to 0700 which will prevent any access from anyone but the user who owns the process.
3. Files created by FileCache use the default umask, instead we'll make this configurable and make it defalt to 0600 so only the user who owns the process can read/write them.
4. Following the cache file mode bits above, we'll also ensure that we create the files securely to prevent against symlink attacks or someone dropping a file with bad permissions before we open it.