Backport nditer buffer reuse fixes

Backports gh-3153 (I somewhat expects python 2.5 or 2.4 won't like the tests, but lets see...)