def chunkread(f, size):
    """Generator that reads from file like object. May return less
     data than requested on the last read."""
    c = f.read(size)
    while len(c):
        yield c
        c = f.read(size)
