Added text to the output image. Also added self._rank field, which was missed in the original repo.