Added exception handling for bitmap conversion