Use three functions to hopefully make eaxmple easier to grasp.
Merge pull request #35 from dnouri/mnist-example-refactor

clean up MNIST example