[Backport] fix persisters writing temporary writing

Fix:
https://jira.codehaus.org/browse/GEOS-6373

- be sure to remove the temp file
- write into same dir of the targhet file