<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_script(path, lines, chmod=True):
        '''write a script with some lines content to path in the image. This
           is done by way of adding echo statements to the install section.

           Parameters
           ==========
           path: the path to the file to write
           lines: the lines to echo to the file
           chmod: If true, change permission to make u+x

        '''
        if len(lines) > 0:
            lastline = lines.pop()
        for line in lines:
            self.install.append('echo "%s" >> %s' %path)
        self.install.append(lastline)     

        if chmod is True:
            self.install.append('chmod u+x %s' %path)