Refactor to use dispatch_io for tasks, and wait for EOF

Hopefully resolves #139, #135, #161.

/cc @joshaber @keithduncan
I seem to recall that `as` distributes over optionals, so this *might* work:

```swift
data as NSData ?? NSData()
```