used rawurlencode instead of urlencode
urlencode encodes spaces as + symbols while rawurlencode encodes them as %20

http://stackoverflow.com/questions/12555128/what-is-the-difference-between-urlencode-and-rawurlencode