Move ctypes error checkers into separate module
[Fix #63] Set proper flags on pipe fds

Force pipe fds into non-blocking mode, and close them on `exec`.  If
available, use `pipe2` from `os` or libc via `ctypes` to create the pipe
with proper flags right away, or fallback to `os.pipe` and manually set
the flags.