def _create_image(self, matrix, width, height, pad):
image = Image.new("<STR_LIT>", (width + (pad * <NUM_LIT:2>),<EOL>height + (pad * <NUM_LIT:2>)), self.bg_colour)<EOL>image_draw = ImageDraw.Draw(image)<EOL>block_width = float(width) / self.cols<EOL>block_height = float(height) / self.rows<EOL>for row, cols in enumerate(matrix):<EOL><INDENT>for col, cell in enumerate(cols):<EOL><INDENT>if cell:<EOL><INDENT>image_draw.rectangle((<EOL>pad + col * block_width,  <EOL>pad + row * block_height,  <EOL>pad + (col + <NUM_LIT:1>) * block_width - <NUM_LIT:1>,  <EOL>pad + (row + <NUM_LIT:1>) * block_height - <NUM_LIT:1>  <EOL>), fill=self.fg_colour)<EOL><DEDENT><DEDENT><DEDENT>stream = BytesIO()<EOL>image.save(stream, format="<STR_LIT>", optimize=True)<EOL>return stream.getvalue()<EOL>
Generates a PNG byte list