Fix for #5313: PyArray_AsCArray caused segfault with 3D-arrays

This fix addresses issue #5313 and should now be fixed.
Many thanks to juliantaylor for the tips.