Write files to disk, creating intermediate directories if they don't exist.