Retain permissions when copying files.

Fixes JENKINS-14269
https://issues.jenkins-ci.org/browse/JENKINS-14269