Throw IOExceptions on bogus input.

Previously we were throwing various unchecked exceptions and this was
causing services to be unhappy.
Merge pull request #161 from square/jwilson_1008_ioexceptions

Throw IOExceptions on bogus input.