import struct


def parse_images(filename):
    """
    Reading images information and converting from bytearray to list of ints
    with help of python's struct module.
    """
    images = []
    imgs_file = open(filename, 'rb')
    # Get only the size of following data
    size = struct.unpack(">IIII", imgs_file.read(16))[1]
    for _ in range(size):
        # Read whole image pixel and unpack it from unsigned bytes to integers
        barray = imgs_file.read(784)
        img = list(struct.unpack("<" + "B"*784, barray))
        images.append(img)

    return images