Fix buggy resize of output Mat in cv::batchDistance (bug #3172)

DescriptorMatcher::knnMatch calls cv::batchDistance repeatedly, once
for every target image. If one of the target images has fewer keypoints
than the k parameter, then batchDistance would resize, and thereby
discard the contents of, the dist Mat, which is supposed to be updated.

The faulty resizing has been fixed, and replaced with a check that the
dist Mat still has the expected size.

http://code.opencv.org/issues/3172