moved nogil from method definition to extern definition

I forget one nogil in previous commit. So move every nogil in lib.cpp into cdef extern statement.