Padding ndarray with zeros to support downsampling by any integer factor