A historic building in Sanquhar that once served as a jail is set to undergo essential renovations works to preserve its rich heritage.