The file is opened correctly from the command line but it doesn't save. After some research I found out it's because url(0).url() returns the url beginning with "file://". Seems like it isn't properly handled by save function (possible bug?). I replaced it with url(0).pathOrUrl() and it works just fine. Quite magically decide whether use path or url. The only thing I didn't check is saving to remote host but opening and local saving is OK.