Right now it always defaults to PNG. How to do this? Maybe we don't call `dialog.remove()`? Check if this won't cause a memory leak.