np.unravel_index is buggy pre-Numpy 1.6 so use np.indices instead