Handle the case where allocations fail in C callbacks of stream.c.

The strategy is to use a pre-allocated integer object with the value
UV_ENOMEM, and pass it to the Python callaback in such a case.

This changeset also fixes a number of reference count bugs.