Updates to gallery plugin

Got some help from __number5__ in the #pelican IRC chat last night. Prior to making these changes to the gallery plugin and template code, Pelican would not build the site.