stat file before sending it uncompressed

This is a cleaner version of #48. It removes the commented-out version of the code, and gets it right in one commit. Please merge this or #48.