Refactor to use dispatch_io for tasks, and wait for EOF

Hopefully resolves #139, #135, #161.

/cc @joshaber @keithduncan
I don't see why. It's pretty closely related to the `Task` stuff, and I don't think there should be a one-to-one mapping between types and files.