Speed up ndarray.flat() for C-contiguous arrays

Currently, ndarray.flat() is quite slow on multi-dimensional arrays. This PR specializes flat() for C-contiguous arrays, with a much faster implementation (2x faster on 2d arrays, more on 3d arrays, etc.).

Note the generic flat() implementation could probably be improved as well.

This PR is based on PR #816.