<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _write(self, text, x, y, colour=Screen.COLOUR_WHITE, attr=Screen.A_NORMAL, bg=Screen.COLOUR_BLACK):
 """ Write some text to the specified location in the current image. :param text: The text to be added. :param x: The X coordinate in the image. :param y: The Y coordinate in the image. :param colour: The colour of the text to add. :param attr: The attribute of the image. :param bg: The background colour of the text to add. """

        # Limit checks to ensure that we don't try to draw off the end of the arrays
        if y >= self._height or x >= self._width:
            return

        # Limit text to draw to visible line
        if len(text) + x > self._width:
            text = text[:self._width - x]

        # Now draw it!
        self._plain_image[y] = text.join(
            [self._plain_image[y][:x], self._plain_image[y][x + len(text):]])
        for i, _ in enumerate(text):
            self._colour_map[y][x + i] = (colour, attr, bg)