Default Firmware upgrade encountered an issue.Please select recovery mode in kies & try again

I tried to root(for the first time) my s4 i9500 using odin.After clicking on 'start' the process failed and whenever I try to turn on my phone it says "Firmware upgrade encountered an issue.Please select recovery mode in kies & try again".I can still get into downloading mode by pressing volume up,power and home button.
I tried my best using kies but it didn't recognize my device.At the moment I'm downloading a custom stock for my device and I'll try to install it using Odin.Please help me out guy