Fix ImageProvider and FileProvider bugs on generating private url for reference (refactored)

https://github.com/sonata-project/SonataMediaBundle/pull/234

This is the same as the above mentioned PR, I just squashed some commits and rebased it again.