import io
import zipfile


def create_zip(files):
    """
    Write all given files in a dict to a ZIP file and return it as raw data
    """
    byte_file = io.BytesIO()
    zip_file = zipfile.ZipFile(byte_file, 'w', zipfile.ZIP_DEFLATED)

    for file_name, file_data in files.iteritems():
        zip_file.writestr(file_name, file_data)

    zip_file.close()
    return byte_file.getvalue()