Properly escape % signs in format strings