use buffer to speed up converting MNIST data into FANN format