Custom icons are added using the infoButtons option, as you can see in the source code of this page. You should use the onSelect event handler, which is called when the viewer opens or the image changes, to change the behavior of the custom icon according to the current image.
A custom download icon has been added to the right of the viewer's info bar (at bottom). Clicking on the icon opens the full image in a new window, from which it can be easily saved.
Unfortunately, opening a file download panel using javascript isn't supported at the moment.
A cart button has been added next to the download button. Notice how the onSelect event populates data based on the current image. The data is then used by the cart button's click event. In the example it just alerts something, but you could implement the cart function by connecting to a web service.