code for generating and comparing images

This can be put inside the self.generate_or_test