Fixing saving problems

There were a few problems with saving.

1. The code was concatenating base path and file name prior to checking if filename was empty therefore bypassing the check every time.

2. The code was escaping the path and then checking whether that path exists which resulted in bypassing the check every time.

I have fixed both.