implemented bits_from_image function