fixed function to generate barcode image
starting to adjust Template.py