Minor fixes to make matplotlib easier on PyPy

- Add fallback implementation for np.add.accumulate()
- Surround array flag access by safeguards
- Make sure that scalars are passed to C functions as Python int's
  or float's.