lets start brand new. so this code is binary and 8 bits, we need to make it ternary and 12 bits for enc and dec and make it start correctly give me the whole code after import time
import os
from PIL import Image

# Paths for input and output images
in_path = "source/input"
out_path = "source/out"

def encode_image(image_path, message, output_path):
    """Encode a message into an image."""
    img = Image.open(image_path)
    width, height = img.size

    binary_message = [format(ord(i), '08b') for i in message]
    binary_message = ''.join(binary_message)

    if len(binary_message) > width * height:
        print("Message is too long")
        return None

    index = 0
    for x in range(width):
        for y in range(height):
            try:
                r, g, b, a = img.getpixel((x, y))
            except:
                r, g, b = img.getpixel((x, y))
            if index < len(binary_message):
                new_r = (r & ~1) | int(binary_message[index])
                img.putpixel((x, y), (new_r, g, b))
                index += 1

    img.save(output_path)
    print("Encoded!\n")

def decode_image(image_path):
    """Decode a message from an image."""
    img = Image.open(image_path)
    width, height = img.size
    binary_message = []

    for x in range(width):
        for y in range(height):
            try:
                r, g, b, a = img.getpixel((x, y))
            except:
                r, g, b = img.getpixel((x, y))
            binary_message.append(r & 1)

    binary_message = ''.join(str(i) for i in binary_message)
    message = [chr(int(binary_message[i: i+8], 2)) for i in range(0, len(binary_message), 8)]
    message = ''.join(message)

    return message.split('ÿ')[0]

def start():
    print(f'This steganography only works for .png\nBuild by Kmz.\n{"_" * 40}\nMenu : \n1. Encode\n2. Decode\n{"_" * 40}')
    option = input('What do you want to do? (1-2) : ')
    option = int(option)
    if option in [1, 2]:
        if option == 1:
            print('---Encoding---')
            file = input('File name: ')
            file += ".png"
            img = Image.open(f'{in_path}/{file}')
            message = input('Message: ')
            output_file = f'{file}-result.png'
            encode_image(f'{in_path}/{file}', message, f'{out_path}/{output_file}')
            print("Encoded!\n")
            time.sleep(1.5)
            for i in range(4):
                os.system('cls')
                print(f"Loading to decode the image {i*'. '}")
                time.sleep(1)
            imgs = Image.open(f'{out_path}/{output_file}')
            print(f"{'-' * 30}\nDecoded text: {decode_image(f'{out_path}/{output_file}')}")
        elif option == 2:
            print('---Decoding---')
            file = input('File name: ')
            try:
                imgs = Image.open(f'{out_path}/{file}.png')
                for i in range(3):
                    os.system('cls')
                    print(f"Loading to decode the image {(i+1)*'. '}")
                    time.sleep(1)
                print(f"{'-' * 30}\nDecoded text from {file}.png: {decode_image(f'{out_path}/{file}.png')}")
            except:
                print('ERROR! This can be caused when the file doesn\'t exist or is corrupted.\n')
    else:
        os.system('cls')
        print('Invalid choice, please input from 1 to 2!')
        start()

if __name__ == "__main__":
    start()