Preserve the permission of the file we download

Related to issue #820