core: fix access of potentially freed memory

Found with python compiled with --with-pydebug

saghul: if the PYUV__PYREF flag is set then it's guaranteed that the
object has a refcount >= 2. If the the flag is not set, however, it's
possible that we arrive here with a refcount of 1, then the first
Py_DECREF would free the object, and immediately after we'd check the
flags of such dead object.

I guess this never blew up IRL because nobody overwrites the memory, but
when running with a debug build, memory is overwritten, precisely to
help catch this kind of bugs. Nice catch @geertj!