Fixed some type incompatibilities, added image conversion