Use specified encoding for filesystem storage
Use safer write to avoid corruption of data.