Added render-to-file function to save directly to a file.