Correctly handle larger files. Add signal handlers.
Correctly handle larger files. Add signal handlers.

* Makes sure that larger images files are completly written out to the socket before closing.
* Correctly reads in the data from files.
* Adds signal handles for SIGHUP and SIGPIPE.

chocklymon/CS360,chocklymon/CS360,chocklymon/CS360,chocklymon/CS360