Allow setting $format in save() method

I'm usually working on temporary files which are given arbitrary names and a "tmp" extension. I needed a way to overwrite the format detection (which is based on file name's extension) in the save() method. I added a optional $format variable. Usage is consistent with the output() method.