Write mnist data to image files