MAINT: remove unused goto label and useless casts
FIX: some more casts in ufunc_object

Introduced a helper function to get rid of repetitive code.