convert MNIST images into FANN format