Added retries on fs.chmod to avoid errors while restoring permissions.

WARNING: this is a temporary fix which uses synchronous methods.
The real synchro mechanism to implement is not yet understood.
Merge pull request #2 from yves-del-medico/permissions

Added retries on fs.chmod to avoid errors while restoring permissions.