write mnist data to images