fix a bug with multiple images; thanks to saiko of tahta.ch for reporting it