Write tree to disk