preserve ownership and permissions of existing file

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
dont fail if result is empty file

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
Merge branch 'issue/315' of https://github.com/asteven/cdist
++changes

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>