adding callback options for onload and onerror events

Adds an option to pass a custom callback that is fired after an image is loaded, or after an error occurs.