write(): avoid copy if data is already in C-order

Also, allow 'array-like' as input