BUG: make ndarray.put respect writeable flag.

Cleaned up  #5132 and added test.