SPARK-2368 Making FileServerHandler sends gracefully to prevent OOM

Busy wait for the channel to be ready before writing to it to prevent
the buffer from exploding.

Also making some small code changes for clarity.
good catch! Will test it.