As @Bergi wrote, you can just replace all the characters:
function encoePicture(pictureUrl)
{
var map=
{
'&': '%26',
'<': '%3c',
'>': '%3e',
'"': '%22',
"'": '%27'
};
var encodedPic = encodeURI(pictureUrl);
var result = encodedPic.replace(/[&<>"']/g, function(m) { return map[m];});
return result;
}