Create root directory before write_page is called

write_page uses the conf.ROOT directory before it gets created. I moved up the directory creation before the write_page calls.