fsu_ecp: Fix "Bad file descriptor" and file mode bits

copy_file() has its file descriptors mixed up, this results in "Bad file
descriptor" when GETting or PUTting files.  Further improve the error
handling and fix the permission bits of created files.