Major rewrite to save_layers_to_files.jsx to improve speed and scalability.