Python: better handling of NumPy integers; closes #576