Refactor the pictures controller to respond to JSON