def serialize_to_json_file(opts, appState, movie, file_path, gzipped=True):
    """ Takes live Durdraw movie objects and serializes them out to a JSON files
    """
    colorMode = appState.colorMode
    if gzipped:
        opener = gzip.open
    else:
        opener = open
    with opener(file_path, 'wt') as f:
        movieDataHeader = {
            'formatVersion': opts.saveFileFormat,
            'colorFormat': colorMode, # 16, 256
            'preferredFont': 'fixed',   # fixed, vga, amiga, etc.
            'encoding': appState.charEncoding,
            'name': '',
            'artist': '',
            'framerate': opts.framerate,
            'sizeX': movie.sizeX,
            'sizeY': movie.sizeY,
            'extra': None,
            'frames': None,
            }
        frameNumber = 1
        fullMovie = {'DurMovie': movieDataHeader}
        fullMovieFrames = []
        for frame in movie.frames:
            content = ''
            newFrame = []
            newColorMap = []
            for posX in range(0, movie.sizeX):
                newColorMap.append(list())
                for posY in range(0, movie.sizeY):
                    #newColorMap[posX].append(list(frame.colorMap[posY, posX]))
                    try:
                        newColorMap[posX].append(frame.newColorMap[posY][posX])
                    except Exception as E:
                        print(E)
                        pdb.set_trace()
            for line in frame.content:
                content = ''.join(line)
                newFrame.append(content)
            serialized_frame = {
                'frameNumber': frameNumber,
                'delay': frame.delay,
                'contents': newFrame,
                'colorMap': newColorMap,
            }
            fullMovieFrames.append(serialized_frame)
            frameNumber += 1
        fullMovie['DurMovie']['frames'] = fullMovieFrames
        fullMovieJSON = json.dumps(fullMovie, indent=2)
        newMovieJSON = clean_up_json_output(fullMovieJSON)
        f.write(newMovieJSON)
    f.close()
 Takes live Durdraw movie objects and serializes them out to a JSON files
    
durdraw/durdraw_file.py