def is_jpeg(image):
    """Returns True if a byte string appears to contain a jpeg."""
    if image[:2] != b'\xff\xd8':
        return False
    if image[-2:] != b'\xff\xd9':
        return False
    return True