improved file save handling