Preprocessing the MNIST dataset