Stricter type checking for ndarray conversion

Fixes #276