There are several tasks you need to perform when you choose to do with custom code. And I personally think they're complicated tasks. Here is the list of what I can imagine.
- Hook to the category edit page to add a new form for upload image. This can be done with the hook
- Handle the image upload. Depend on what you want the upload field to be, it can be a HTML
file input or a button to open the Media Library popup.
- If it's just a
file input, then you have to work with pure PHP to handle upload via
- If it uses Media Library, then you need to work with JS to trigger the popup.
As you're developing a theme, it can take a lot of time working on that. Besides, it belongs to plugin territory.
So, I'd suggest using a plugin for that. Meta Box framework with MB Term Meta extension works great in this case.
Disclaimer: I'm the author of Meta Box.