conf: don't overwrite a configuration file on serialization error

When a serilization error occurs, the resulting file is empty. We wrap
the file object to write to a temporary file and overwrite the file
only when the whole process has succeeded.
conf: fix right permissions of generated file to 644
Merge pull request #22 from vincentbernat/fix/no-empty-conf

conf: don't overwrite a configuration file on serialization error