Avoid state dir errors when it doesn't exist

Make sure to create the state file path before attempting to write it.  This is currently only done for the config dir, which may be different.