'Saves the data in image_data to the location image_path. Returns True/False
to represent success or failure.
image_data: binary image data to write to file
image_path: file location to save the image to'

def _write_image(self, image_data, image_path, obj=None):

    assert isinstance(image_path, six.text_type)
    if ek(os.path.isfile, image_path):
        logger.log(u'Image    already    exists,    not    downloading', logger.DEBUG)
        return False
    image_dir = ek(os.path.dirname, image_path)
    if (not image_data):
        logger.log(u'Unable    to    retrieve    image    to    save    in    {0},    skipping'.format(image_path), logger.DEBUG)
        return False
    try:
        if (not ek(os.path.isdir, image_dir)):
            logger.log((u"Metadata    dir    didn't    exist,    creating    it    at    " + image_dir), logger.DEBUG)
            ek(os.makedirs, image_dir)
            helpers.chmodAsParent(image_dir)
        outFile = io.open(image_path, u'wb')
        outFile.write(image_data)
        outFile.close()
        helpers.chmodAsParent(image_path)
    except IOError as e:
        logger.log((((u'Unable    to    write    image    to    ' + image_path) + u'    -    are    you    sure    the    show    folder    is    writable?    ') + ex(e)), logger.ERROR)
        return False
    return True
