Correct error in writing to numpy array