Fixed conditional writing in Cython