One sentence suffers from clarity issues, while each of them could be cleaned up to sound more natural, as well as for readability.
Regarding your first sentence:
- Three weeks ago, I was writing a short essay for five days.
This is essentially clear. There's not much else it could mean beyond there being a point in the recent past during which you spent a five-day period of time working on an essay.
Written more naturally, it would be:
Three weeks ago, I spent five days writing a short essay.
Or:
Three weeks ago, it took me five days to write a short essay.
As for sentence number two:
- John was scoring a lot of goals for many years.
This one needs some clarity. Are you trying to say that John was a big goal-scorer before, but now things are different? Are you saying John scored a lot of goals until something happened to change that? It's not obvious what the sentence is trying to say, but here are some options for a rewrite:
For many years, John scored a lot of goals.
Or:
For many years, John had been scoring a lot of goals—until...
Or:
John had scored many goals over the years.
Without context, though, it's impossible to determine which best communicates your intent.
And then, sentence number three:
- During Tim's one-week stay in my home, I was working on my project
for five days.
Again, this one's pretty clear, but awkwardly worded, which impedes its effectiveness.
A different option:
During Tim's one-week stay in my home, I spent five days working on my
project.
Or:
The week Tim stayed with me, I spent five days working on my
project.