Estudiaba con Juan - I don't think this action is still being in process. :)
* Por aquel entonces, estudiaba con Juan. --> You can talk about the past using the imperfect. Remember that when we describe something, we use the imperfect.
* Mientras estudiaba con Juan, mi madre llamó al timbre. --> An interrupted action.
* Yo estudiaba con Juan. --> As I said before, you can be referring to the past, to an ended process with this.
* I needed the books. --> (Necesitaba los libros) Is an ended action, I would say you are describing something, an action.
Estudié con Juan - Clear that the process is ended.
* Estudié con Juan
durante tres horas. --> You finished studying with him.
* Estudié con Juan
hace cinco años.
* Estudié con Juan
en la facultad.
Can you see any diference, Malta? When you use the perfect tense you need to specify when it was more or less. However, if you use the imperfect, you are just describing an action. So, that action should be ended before you can describe it, shouldn't it?
Just hope it helps!
Okay, all this from my point of view.
Others might not agree with this!